import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)
import Layout from '@/layout'

export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },

  {
    path: '/404',
    component: () => import('@/views/error/404'),
    hidden: true
  },

  {
    path: '/',
    component: Layout,
    redirect: '/home',
    children: [{
      path: 'home',
      name: 'Home',
      component: () => import('@/views/home/index'),
      meta: { title: '首页', icon: 'el-icon-s-home', affix: true }
    }]
  },

  // {
  //   path: '/system',
  //   component: Layout,
  //   redirect: '/system/user',
  //   name: 'System',
  //   meta: { title: '系统管理', icon: 'el-icon-setting' },
  //   children: [
  //     {
  //       path: 'user',
  //       name: 'User',
  //       component: () => import('@/views/system/user/index'),
  //       meta: { title: '用户', icon: 'el-icon-user' }
  //     },
  //     {
  //       path: 'role',
  //       name: 'Role',
  //       component: () => import('@/views/system/role/index'),
  //       meta: { title: '角色', icon: 'el-icon-lock' }
  //     },
  //     {
  //       path: 'menu',
  //       name: 'Menu',
  //       component: () => import('@/views/system/menu/index'),
  //       meta: { title: '菜单', icon: 'el-icon-menu' }
  //     }
  //   ]
  // },

  // {
  //   path: '/pos',
  //   component: Layout,
  //   redirect: '/pos/sale',
  //   name: 'Pos',
  //   meta: { title: '销售管理', icon: 'el-icon-s-help' },
  //   children: [
  //     {
  //       path: 'roomType',
  //       name: 'roomType',
  //       component: () => import('@/views/pos/roomType/index'),
  //       meta: { title: '房型', icon: 'el-icon-box' }
  //     },
  //     {
  //       path: 'roomInfo',
  //       name: 'roomInfo',
  //       component: () => import('@/views/pos/roomInfo/index'),
  //       meta: { title: '房间', icon: 'el-icon-goods' }
  //     },
  //     {
  //       path: 'roomSale',
  //       name: 'roomSale',
  //       component: () => import('@/views/pos/roomSale/index'),
  //       meta: { title: '订单', icon: 'el-icon-shopping-cart-full' }
  //     },
  //     {
  //       path: 'roomOrder',
  //       name: 'roomOrder',
  //       component: () => import('@/views/pos/roomOrder/index'),
  //       meta: { title: '预定&入住', icon: 'el-icon-wallet' }
  //     },
  //     {
  //       path: 'saleData',
  //       name: 'saleData',
  //       component: () => import('@/views/pos/saleData/index'),
  //       meta: { title: '报表', icon: 'el-icon-s-data' }
  //     }
  //   ]
  // },

  // {
  //   path: 'external-link',
  //   component: Layout,
  //   children: [
  //     {
  //       path: 'https://panjiachen.github.io/vue-element-admin-site/#/',
  //       meta: { title: 'VAT官网', icon: 'link' }
  //     }
  //   ]
  // },

  { path: '*', redirect: '/', hidden: true }
]

const createRouter = () => new Router({
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher
}

export default router
